package nine.test_9_21;

import java.util.Map;
import java.util.Scanner;

public class TestMain2 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int m = scanner.nextInt();
        int t = scanner.nextInt();
        int[] hash = new int[n];
        int[][] arr = new int[n][n];
        for (int i = 0; i < m; i++) {
            int a = scanner.nextInt();
            int b = scanner.nextInt();
            int c = scanner.nextInt();
            hash[a] = 1;
            hash[b] = 1;
            hash[c] = 1;
            arr[a][b] = 1;
            arr[a][c] = 1;
            arr[b][a] = 1;
            arr[c][a] = 1;
            arr[b][c] = 1;
            arr[c][b] = 1;
        }
        for (int i = 0; i < t; i++) {
            int x = scanner.nextInt();
            int y = scanner.nextInt();
            if(arr[x][y] == 1) {
                System.out.println(1);
            }
            boolean bb = false;
            int min = Math.min(x,y);
            int max = Math.max(x,y);
            for (int j = min; j <= max; j++) {
                if(hash[j] == 0 ) {
                    bb = true;
                }
                if(j != 0) {
                    if (arr[j][j - 1] == 0) {
                        bb = true;
                    }
                } else {
                    if (arr[j][n - 1] == 0) {
                        bb = true;
                    }
                }
            }
            if (bb == true) {
                boolean b = false;
                for (int j = max; j <= n + min; j++) {
                    if(hash[j % n] == 0) {
                        b = true;
                    }
                    if(j % n != 0) {
                        if (arr[j % n][j % n - 1] == 0) {
                            bb = true;
                        }
                    } else {
                        if (arr[j % n][n - 1] == 0) {
                            bb = true;
                        }
                    }
                }
                if(b == false) {
                    bb = false;
                }

            }

            if(bb == false) {
                System.out.println(2);
            } else {
                System.out.println(3);
            }
        }
    }

}
